//
//  HQVisitorViewController.m
//  wbOC
//
//  Created by sheji on 16/3/3.
//  Copyright (c) 2016年 sheji. All rights reserved.
//

#import "HQVisitorViewController.h"
#import "HQVisitorView.h"

@interface HQVisitorViewController ()
/**
 *  访客视图
 */
@property (nonatomic, strong)HQVisitorView *visitorView;
@end

@implementation HQVisitorViewController


-(void)loadView
{
    self.userLogon = NO;
    self.userLogon ? [super loadView] : [self setupVisitorView];
}
#pragma mark - 设置界面
/**
 *  设置访客视图
 */
-(void)setupVisitorView
{
    self.view = [[HQVisitorView alloc]init];
    self.view = self.visitorView;
}

/**
 *  设置界面
 */
-(void)setupUIWithImageName:(NSString *)imageName message:(NSString *)message logonSuccessBlock:(void (^)())loginSuccessBlock
{
    if (!self.userLogon) {
        self.navigationItem.leftBarButtonItem = [UIBarButtonItem barButtonWithTitle:@"" imageName:nil target:self action:@selector(clickregisterButton)];
        self.navigationItem.rightBarButtonItem = [UIBarButtonItem barButtonWithTitle:@"" imageName:nil target:self action:@selector(clickloginButton)];
        
        //设置访客视图
        [self.visitorView visitorInfoWihImageName:imageName message:message];
        
        //添加按钮监听的方法
        [self.visitorView.registerButton addTarget:self action:@selector(clickregisterButton) forControlEvents:UIControlEventTouchUpInside];
        [self.visitorView.loginButton addTarget:self action:@selector(clickloginButton) forControlEvents:UIControlEventTouchUpInside];
        
    }else if (loginSuccessBlock != nil){
        loginSuccessBlock();
    }
}
#pragma mark - 监听方法
-(void)clickregisterButton
{
    NSLog(@"你点击了注册");
}
-(void)clickloginButton
{
    NSLog(@"你点击了登录");
}
@end
